package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.LineBaseBigType;
import com.sailfish.springbootdemo.pojo.db1.LineBaseSmallType;
import com.sailfish.springbootdemo.service.db1.LineBaseSmallTypeService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/lineBaseSmallType")
public class LineBaseSmallTypeController {

    @Autowired
    private LineBaseSmallTypeService lineBaseSmallTypeService;

    @PostMapping("/getAllLineBaseSmallTypeByBigType")
    public Result getAllLineBaseSmallTypeByBigType(String searchValue, Integer lineBaseBigTypeId) {
        try {
            return ResultUtil.success(lineBaseSmallTypeService.getAllLineBaseSmallTypeByBigType(searchValue, lineBaseBigTypeId));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/addOrUpdateLineBaseSmallType")
    public Result addOrUpdateLineBaseSmallType(LineBaseSmallType lineBaseSmallType, String mode) {
        return lineBaseSmallTypeService.addOrUpdateLineBaseSmallType(lineBaseSmallType, mode);
    }

    @PostMapping("/deleteLineBaseSmallType")
    public Result deleteLineBaseSmallType(Integer lineBaseSmallTypeId) {
        return lineBaseSmallTypeService.deleteLineBaseSmallType(lineBaseSmallTypeId);
    }
}
